import { createSlice, PayloadAction } from '@reduxjs/toolkit';

export interface TutorialState {
  steps: any[];
  tourStep: number;
  tourRunning: boolean;
  requestedTourStep: number | null;
  lastCheckRender: any;
}

const initialState: TutorialState = {
  steps: [],
  tourStep: 0,
  tourRunning: false,
  requestedTourStep: null,
  lastCheckRender: null,
};

const tutorialSlice = createSlice({
  name: 'tutorial',
  initialState,
  reducers: {
    setSteps: (state, action: PayloadAction<any[]>) => {
      state.steps = action.payload;
    },
    setTourStep: (state, action: PayloadAction<number>) => {
      state.tourStep = action.payload;
    },
    setTourRunning: (state, action: PayloadAction<boolean>) => {
      state.tourRunning = action.payload;
    },
    setRequestedTourStep: (state, action: PayloadAction<number | null>) => {
      state.requestedTourStep = action.payload;
    },
    setLastCheckRender: (state, action: PayloadAction<any>) => {
      state.lastCheckRender = action.payload;
    },
  },
});

export const {
  setSteps,
  setTourStep,
  setTourRunning,
  setRequestedTourStep,
  setLastCheckRender,
} = tutorialSlice.actions;

export default tutorialSlice.reducer;

